import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    montmorilloniteLayer:false,
    uploadedSuccessfully:false,
    editData:false,
    scope:{},
  },
  getters:{},
  mutations: {
    updataOpenEvent:(state) => {
      state.uploadedSuccessfully = false
      return state.montmorilloniteLayer = true
    },
    updataDownEvent:(state,index) => {
      if(index == 0) return state.montmorilloniteLayer = false;
      if (index == 1) {
        state.uploadedSuccessfully = true
      }
    },
    editDataEvent:(state,e) => {
      state.scope = e
      state.montmorilloniteLayer = false
      return state.editData = true
    },
    editShutDown:(state,form) => {
      if(form != 0){
        if (form.name != '') {
          state.scope.name = form.name
        }

        if (form.tenderAnnouncement != '') {
          state.scope.tenderAnnouncement = form.tenderAnnouncement
        }

        if (form.city != '') {
          state.scope.city = form.city
        }

        if (form.phone != '') {
          state.scope.phone = form.phone
        }
      }
      state.montmorilloniteLayer = false
      return state.editData = false
    },
    allHidden:(state) => {
      state.montmorilloniteLayer = false
      state.editData = false
    }
  },
  actions: {
  },
  modules: {}
})
